package com.zhengtoon.mctoon.conv.controller;

import com.bjtoon.framework.sdk.toon.censor.entity.CensorResult;
import com.zhengtoon.mctoon.conv.service.ConvCommentService;
import com.zhengtoon.mctoon.conv.vo.AuditVo;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 评论管理
 */
@RestController
@RequestMapping("/comment")
@Api(value = "comment", description = "comment")
public class CommentAuditController {

    private static final Logger log = LoggerFactory.getLogger(CommentAuditController.class);

    @Autowired
    private ConvCommentService convCommentService;

    @ApiOperation(value = "pass", httpMethod = "GET", notes = "pass")
    @RequestMapping(value = "/pass")
    public CensorResult pass(
            @ApiParam(required = true, name = "auditVo", value = "auditVo") AuditVo auditVo) {
        if (StringUtils.isBlank(auditVo.getObjectId())) {
            return CensorResult.FAIL_RESULT;
        }
        log.info("==============(审核通过)处理成功===================" + auditVo.getObjectId());
        int rs = convCommentService.updateCommentPass(auditVo.getObjectId());
        if (rs < 1) {
            return CensorResult.FAIL_RESULT;
        }
        return CensorResult.SUCCESS_RESULT;
    }

    @ApiOperation(value = "fail", httpMethod = "GET", notes = "fail")
    @RequestMapping(value = "/fail")
    public CensorResult fail(
            @ApiParam(required = true, name = "objectId", value = "objectId") AuditVo auditVo) {
        if (StringUtils.isBlank(auditVo.getObjectId())) {
            return CensorResult.FAIL_RESULT;
        }
        log.info("==============(审核不通过)处理成功===================" + auditVo.getObjectId());
        int rs = convCommentService.updateCommentFail(auditVo.getObjectId());
        if (rs < 1) {
            return CensorResult.FAIL_RESULT;
        }
        return CensorResult.SUCCESS_RESULT;
    }


}